/* ******************************************************************
 * This file is part of the escal project and distributed under the
 * terms of the GNU General Public License Version 3
 * CopyRight (C) 2008 Epocher (xijiaosdq@gmail.com)
 * See COPYING file for licensing information.
 *******************************************************************/

#ifndef FTP_LINK_MANAGER_H
#define FTP_LINK_MANAGER_H
#include "link_manager.h"
#include <QFtp>

class FtpLinkManager:public BaseLinkManager{
	Q_OBJECT
public:
	FtpLinkManager(FileManager *fileManager, const QUrl &url,
			QObject *parent=0);
	~FtpLinkManager();
	void stop();
protected:
	void run();
	void cleanUp();
protected slots:
	void startDownload();
	void readData( );
	void ftpRequestDone(bool error);
	void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
private:
	FileManager *fileManager;
	QUrl url;
	QFtp ftp;
	int pieceIndex;
	qint64 offset;
	int status;
	bool reconnect;
	bool quit;
	bool gotPiece;
};

#endif /* FTP_LINK_MANAGER_H */
